class UserServe {
  constructor() {
    this.arr = Array.from({ length: 10 }, (_, i) => i);
  }

  // 查询数据表中记录
  async find() {
    await new Promise(resolve => setTimeout(resolve, 1 * 1000));

    return this.arr;
  }

  // 更新数据表中记录
  async add(data) {
    await new Promise(resolve => setTimeout(resolve, 1 * 1000));

    this.arr.push(data);
    return this.arr;
  }

  // 更新数据表中记录
  async update(id, data) {
    await new Promise(resolve => setTimeout(resolve, 1 * 1000));

    this.arr[id] = data;
    return this.arr;
  }

  // 删除数据表中记录
  async remove(id) {
    await new Promise(resolve => setTimeout(resolve, 1 * 1000));

    this.arr.splice(id, 1);
    return this.arr;
  }
}

module.exports = new UserServe();
